package com.gibs.peixunapi.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.gibs.peixunapi.model.VideoClass;

@Repository
public interface VideoClassDao extends JpaRepository<VideoClass, Integer>, JpaSpecificationExecutor<VideoClass> {

	@Query("from VideoClass where name = ?1")
	List<VideoClass> find(String name);

	@Query("from VideoClass where name like ?1")
	List<VideoClass> findLike(String name);

	@Query(value = "select * from VideoClass limit ?, ?", nativeQuery = true)
	List<VideoClass> findPage(Integer offset, Integer size);

	@Query(value = "select * from VideoClass where name = ? limit ?, ?", nativeQuery = true)
	List<VideoClass> findPage(String name, Integer offset, Integer size);

	@Query(value = "select * from VideoClass where name like ? limit ?, ?", nativeQuery = true)
	List<VideoClass> findPageLike(String name, Integer offset, Integer size);

	@Query(value = "select count(*) from VideoClass where name = ?", nativeQuery = true)
	Long count(String name);

	@Query(value = "select count(*) from VideoClass where name like ?", nativeQuery = true)
	Long countLike(String name);
	
	@Query("from VideoClass order by id asc")
	List<VideoClass> findAllAsc();
}

